/*
 * @Author: szx
 * @Date: 2022-02-27 13:01:22
 * @LastEditTime: 2022-02-27 13:12:41
 * @Description:
 * @FilePath: \leetcode\2000-2099\2001\2001.js
 */
/**
 * @param {number[][]} rectangles
 * @return {number}
 */
 var interchangeableRectangles = function (rectangles) {
    const map = new Map();
    for (let i = 0; i < rectangles.length; i++) {
        const tmp = rectangles[i][0] / rectangles[i][1];
        map.set(tmp, (map.get(tmp) || 0) + 1);
    }
    let res = 0;
    for (let ele of map) {
        res += (ele[1] * (ele[1] - 1)) / 2;
    }
    return res;
};
console.log(
    interchangeableRectangles([
        [4, 8],
        [3, 6],
        [10, 20],
        [15, 30]
    ])
);
